package com.kejiguan.ui.model;

import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;

import com.google.gson.annotations.Expose;

import java.io.Serializable;

/**
 * Created by YYY on 2016/4/28.
 */
public class ExhibitionRunItem implements Serializable ,Comparable<ExhibitionRunItem>{

    @Expose
    private String recordId;
    @Expose
    private String equipId;
    @Expose
    private String systemId;
    @Expose
    private String equipType;
    @Expose
    private long knobcount;//旋转次数
    @Expose
    private long handlecount;
    @Expose
    private float current;//电流
    @Expose
    private float voltage;//电压
    @Expose
    private float temperature;//温度
    @Expose
    private long createDate;
    @Expose
    private long clickcount;
    @Expose
    private long machineOperatedCount;
    @Expose
    private ExhibitionNeItem ne;

    private String displayName;
    private String displayId;

    private int currentType=3;


    public String getRecordId() {
        return recordId;
    }

    public void setRecordId(String recordId) {
        this.recordId = recordId;
    }

    public String getEquipId() {
        return equipId;
    }

    public void setEquipId(String equipId) {
        this.equipId = equipId;
    }

    public String getSystemId() {
        return systemId;
    }

    public void setSystemId(String systemId) {
        this.systemId = systemId;
    }

    public String getEquipType() {
        return equipType;
    }

    public void setEquipType(String equipType) {
        this.equipType = equipType;
    }

    public long getKnobcount() {
        return knobcount;
    }

    public void setKnobcount(long knobcount) {
        this.knobcount = knobcount;
    }

    public long getHandlecount() {
        return handlecount;
    }

    public void setHandlecount(long handlecount) {
        this.handlecount = handlecount;
    }

    public float getCurrent() {
        return current;
    }

    public void setCurrent(float current) {
        this.current = current;
    }

    public float getVoltage() {
        return voltage;
    }

    public void setVoltage(float voltage) {
        this.voltage = voltage;
    }

    public float getTemperature() {
        return temperature;
    }

    public void setTemperature(float temperature) {
        this.temperature = temperature;
    }

    public long getCreateDate() {
        return createDate;
    }

    public void setCreateDate(long createDate) {
        this.createDate = createDate;
    }

    public long getClickcount() {
        return clickcount;
    }

    public void setClickcount(long clickcount) {
        this.clickcount = clickcount;
    }

    public long getMachineOperatedCount() {
        return machineOperatedCount;
    }

    public void setMachineOperatedCount(long machineOperatedCount) {
        this.machineOperatedCount = machineOperatedCount;
    }

    public ExhibitionNeItem getNe() {
        return ne;
    }

    public void setNe(ExhibitionNeItem ne) {
        this.ne = ne;
    }

    public String getDisplayName() {

        if (TextUtils.isEmpty(displayName))
        {
            if (equipId.startsWith("Z"))
            {
                displayName=equipId.substring(4);
            }else
            {
                displayName=equipId;
            }
        }
        return displayName;
    }

    public String getDisplayId()
    {
        if (TextUtils.isEmpty(displayId))
        {

            if (equipId.startsWith("Z"))
            {
                Log.d(ExhibitionRunItem.class.getSimpleName(),"equipId:"+equipId);
                displayId=equipId.substring(4);
            }else
            {
                displayId=equipId;
            }
        }
        return displayId;
    }

    public float getValue(int type)
    {
        switch (type)
        {
            case 1:
                return voltage;
            case 2:
                return  temperature;
            case 3:
                return  clickcount;
            case 4:
                return  knobcount;
            case 5:
                return  handlecount;
            case 6:
                return machineOperatedCount;
            case 7:
                return current;
            default:
                return 0;
        }
    }


    public void setCurrentType(int currentType) {
        this.currentType = currentType;
    }

    @Override
    public int compareTo(ExhibitionRunItem another) {
        if (this.getValue(currentType)>another.getValue(currentType))
        {
            return -1;
        }else if (this.getValue(currentType)==another.getValue(currentType))
        {
            return 0;
        }
        return 1;
    }
}
